package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MyResultSetOptions1 {

	public static void main(String[] args) throws ClassNotFoundException,
			SQLException {
		Class.forName("oracle.jdbc.driver.OracleDriver");
		System.out.println("Driver loaded successfully");

		Connection con = DriverManager.getConnection(
				"jdbc:oracle:thin:@10.23.0.100:1521:esgdb10", "scott", "tiger");
		System.out.println("connection established");

		Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
				ResultSet.CONCUR_READ_ONLY);
		System.out.println("Forward direction");
		ResultSet rs = stmt.executeQuery("SELECT * FROM myTabKJ");
		while (rs.next()) {
			System.out.println("ID" + rs.getInt("sro") + "Name"
					+ rs.getString(2));

		}
		System.out.println("Backward direction");
		while (rs.previous()) {
			System.out.println("ID" + rs.getInt("sro") + "Name"
					+ rs.getString(2));

		}
	}
}
